package com.itheima.gateway.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @Description: 登录拦截的全局过滤器
 * @Version: V1.0
 */
@Order(1)  //如果有多个过滤器， Order的值越小越优先执行
@Component   // 扫描
public class LoginFilter1 implements GlobalFilter { //, Ordered


    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

        System.out.println("LoginFilter1......");

        // 放行
        return chain.filter(exchange);
    }

    /**
     * 如果有多个过滤器， Order的值越小越优先执行
     * @return
     */
//    @Override
//    public int getOrder() {
//        return 1;
//    }
}
